package ej1.Main;


import java.util.ArrayList;
import java.util.Iterator;

public class ProblemSolver {

	public Iterable<MutationPath> solve(Iterable<ProblemInstance> problemInstances) {
		
		ArrayList<MutationPath> longestMutationPaths = new ArrayList<MutationPath>();
		
		for (Iterator<ProblemInstance> i = problemInstances.iterator(); i.hasNext();)
			longestMutationPaths.add(solve(i.next()));
		
		return longestMutationPaths;
	}

	private MutationPath solve(ProblemInstance anInstance) {
		
		
		MutationPath longestMutationPath = new MutationPath();
		
		Iterator<Strain> i = anInstance.getStrains().iterator();
		Strain actualStrain;
		
		while(i.hasNext()){

			actualStrain = i.next();

			if (actualStrain.getLongestMutationPathComingFrom(actualStrain).isLongerThan(longestMutationPath))
				longestMutationPath = actualStrain.getLongestMutationPathCache();
		}
			
		System.out.println("" + Strain.PASSES);
		
		return longestMutationPath;
		
	}

}
